<template>
  <div class="count">
    {{ countStore.name }}
    <button @click="loveTalk.getATalk()">获取一句土味情话</button>
    <button @click="loveTalk.getBTalk()">获取一句习语</button>
    <ul>
      <li v-for="item in loveTalk.talks">{{ item }}</li>
    </ul>
  </div>
</template>

<script setup lang="ts" name="loveTalk">
import axios from "axios";
import { reactive } from "vue";
import { useLoveTalkStore } from "@/store/loveTalk";
import { useCountStore } from '@/store/count';
// const talks: Array<string> = reactive([]);

const loveTalk = useLoveTalkStore();
const countStore = useCountStore();
// const getTalk =loveTalk.getATalk();


// 相当于 vue的watch
loveTalk.$subscribe(()=>{
  console.log("lovetalk发生变化");
  localStorage.setItem("loveTalk",JSON.stringify(loveTalk.talks))
})

</script>

<style scoped>
.count {
  background-color: orange;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 0 10px;
}
</style>
